<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>bmqa_confirmeventbuilder Component</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javaScript" src="search/search.js"></script>
<link href="bdedox.css" rel="stylesheet" type="text/css"/>
    <style>
      div.hanging {
        padding-left: 0.75in;
        text-indent: -0.50in;
      }
      div.unhanging {
        text-indent:     0in;
      }
      a.glossary {
        font-weight: bold;
        font-style: italic;
      }
    </style>
</head>
<!--
<body onload='searchBox.OnSelectItem(0);'>
-->
<body>

<table border=2 cellspacing=0 cellpadding=0 align=center>
<tr>
 <td valign=top align=center>
 <p align=center><b><i>Quick Links:</i></b></p>
 </td>
 <td valign=top align=center>
 <p align=center>
<a class="qindex" href="group__bmqa.html" target="_blank">bmqa</a> | <a class="qindex" href="group__bmqpi.html" target="_blank">bmqpi</a> | <a class="qindex" href="group__bmqt.html" target="_blank">bmqt</a>
 </td>
 </tr>
 </table>

  </div>
<!-- Generated by Doxygen 1.7.1 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul class="tablist">
      <li><a href="components.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="components.html"><span>Components</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="summary">
<a href="#namespaces">Namespaces</a>  </div>
  <div class="headertitle">
<h1>Component bmqa_confirmeventbuilder<br/>
<small>
[<a class="el" href="group__bmqa.html">Package bmqa</a>]</small>
</h1>  </div>
</div>
<div class="contents">

<p>Provide a builder for batching confirmation messages.  
<a href="#_details">More...</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="namespaces"></a>
Namespaces</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">namespace &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacebmqp.html">bmqp</a></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">namespace &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="namespacebmqa.html">bmqa</a></td></tr>
</table>
<hr/><a name="_details"></a><h2>Detailed Description</h2>
<dl class="user"><dt><b>Outline</b></dt><dd><ul>
<li>
<a href="#1">Purpose</a> </li>
<li>
<a href="#2">Classes</a> </li>
<li>
<a href="#3">Description</a> <ul>
<li>
<a href="#3.1">Usage</a> </li>
<li>
<a href="#3.2">Example 1 - Basic Usage</a> </li>
<li>
<a href="#3.3">Thread Safety</a> </li>
</ul>
</li>
</ul>
</dd></dl>
<dl class="user"><dt><b></b></dt><dd></dd></dl>
<dl class="user"><dt><b></b></dt><dd><a class="anchor" id="purpose"></a> <a class="anchor" id="1"></a> </dd></dl>
<dl class="user"><dt><b>Purpose: </b></dt><dd>Provide a builder for batching confirmation messages. </dd></dl>
<dl class="user"><dt><b></b></dt><dd></dd></dl>
<dl class="user"><dt><b></b></dt><dd><a class="anchor" id="classes"></a> <a class="anchor" id="2"></a> </dd></dl>
<dl class="user"><dt><b>Classes: </b></dt><dd><table class="doxtable">
<tr>
<td><a class="el" href="classbmqa_1_1ConfirmEventBuilder.html">bmqa::ConfirmEventBuilder</a> </td><td>builder for batching confirmation messages.  </td></tr>
</table>
</dd></dl>
<dl class="user"><dt><b></b></dt><dd></dd></dl>
<dl class="user"><dt><b></b></dt><dd><a class="anchor" id="description"></a> <a class="anchor" id="3"></a> </dd></dl>
<dl class="user"><dt><b>Description: </b></dt><dd>This component implements a mechanism, <code><a class="el" href="classbmqa_1_1ConfirmEventBuilder.html">bmqa::ConfirmEventBuilder</a></code>, that can be used for batching CONFIRM messages. The resulting batch can be sent to the BlazingMQ broker using the <code><a class="el" href="classbmqa_1_1Session.html">bmqa::Session</a></code> (refer to <code>bmqa_session</code> for details). Wherever possible, a BlazingMQ consumer should try to send a batch of CONFIRM messages, which is more efficient than confirming messages individually. </dd></dl>
<dl class="user"><dt><b></b></dt><dd>The builder holds a batch of CONFIRM messages under construction, and provides two flavors of <code>addMessageConfirmation</code> method to add a CONFIRM message to the batch. It also provides a routine to retrieve number of CONFIRM messages added to the batch. Once application is done creating the batch, it can retrieve the blob (wire-representation) of the batch and send it via <code><a class="el" href="classbmqa_1_1Session.html">bmqa::Session</a></code>. See <code>Usage</code> section for more details. </dd></dl>
<dl class="user"><dt><b></b></dt><dd></dd></dl>
<dl class="user"><dt><b></b></dt><dd><a class="anchor" id="usage"></a> <a class="anchor" id="description.usage"></a> <a class="anchor" id="3.1"></a> </dd></dl>
<dl class="user"><dt><b>Usage: </b></dt><dd><ul>
<li>
An instance of <a class="el" href="classbmqa_1_1ConfirmEventBuilder.html">bmqa::ConfirmEventBuilder</a> (the builder) can be used to create multiple batches of CONFIRM messages. The recommended approach is to create one instance of the builder and use it throughout the lifetime of the task (if the task is multi-threaded, an instance per thread must be created and maintained). See usage example #1 for an illustration.  </li>
<li>
The lifetime of an instance of the builder is bound by the <a class="el" href="classbmqa_1_1Session.html">bmqa::Session</a> from which it was created. In other words, <a class="el" href="classbmqa_1_1Session.html">bmqa::Session</a> instance must outlive the builder instance.  </li>
</ul>
</dd></dl>
<dl class="user"><dt><b></b></dt><dd></dd></dl>
<dl class="user"><dt><b></b></dt><dd><a class="anchor" id="example_1_-_basic_usage"></a> <a class="anchor" id="description.example_1_-_basic_usage"></a> <a class="anchor" id="3.2"></a> </dd></dl>
<dl class="user"><dt><b>Example 1 - Basic Usage: </b></dt><dd><div class="fragment"><pre class="fragment">   <span class="comment">// In this snippet, we will send a batch of CONFIRMs for all the</span>
   <span class="comment">// &#39;bmqa::Message&#39; messages received in a &#39;bmqa::MessageEvent&#39;.</span>

   <span class="comment">// Note that error handling is omitted from the snippet for the sake of</span>
   <span class="comment">// brevity.</span>

   <a class="code" href="classbmqa_1_1Session.html">bmqa::Session</a> session;
       <span class="comment">// Session start up logic elided.</span>

   <span class="comment">// Create and load an instance of the ConfirmEventBuilder.  Note that in</span>
   <span class="comment">// this example, we are creating the builder on the stack everytime a</span>
   <span class="comment">// message event is received.  Another approach can be to maintain the</span>
   <span class="comment">// builder as a data member and use it everytime.</span>

   <a class="code" href="classbmqa_1_1ConfirmEventBuilder.html">bmqa::ConfirmEventBuilder</a> builder;
   session.<a class="code" href="classbmqa_1_1Session.html#ae1308efd8c03f795c33bd4c8a48790c4">loadConfirmEventBuilder</a>(&amp;builder);

   <span class="comment">// Assuming that a &#39;bmqa::MessageEvent&#39; is received.</span>

   <a class="code" href="classbmqa_1_1MessageIterator.html">bmqa::MessageIterator</a> iter = messageEvent.messageIterator();
   <span class="keywordflow">while</span> (iter.<a class="code" href="classbmqa_1_1MessageIterator.html#aebcc19c61a0b788c076b1a2ba5cca6bf">nextMessage</a>()) {
       <span class="keyword">const</span> <a class="code" href="classbmqa_1_1Message.html">bmqa::Message</a>&amp; msg = iter.<a class="code" href="classbmqa_1_1MessageIterator.html#ac3edf62526982ad45cc7d0bdb1c07478">message</a>();

       <span class="comment">// Business logic for processing &#39;msg&#39; elided.</span>

       <span class="keywordtype">int</span> rc = builder.<a class="code" href="classbmqa_1_1ConfirmEventBuilder.html#a29309e053c41d827949ec7c4e0e1fbaf">addMessageConfirmation</a>(msg);
           <span class="comment">// Error handling elided.</span>
   }

   <span class="comment">// All messages in the event have been processed and their corresponding</span>
   <span class="comment">// CONFIRM messages have been batched.  Now its time to send the batch to</span>
   <span class="comment">// the BlazingMQ broker.</span>

   <span class="keywordtype">int</span> rc = session.<a class="code" href="classbmqa_1_1Session.html#ad956f64b183e04e20c23ad7b8846eb28">confirmMessages</a>(&amp;builder);
       <span class="comment">// Error handling elided.  Note that in case of success, above method</span>
       <span class="comment">// will also reset the &#39;builder&#39;.</span>
</pre></div> </dd></dl>
<dl class="user"><dt><b></b></dt><dd></dd></dl>
<dl class="user"><dt><b></b></dt><dd><a class="anchor" id="thread_safety"></a> <a class="anchor" id="description.thread_safety"></a> <a class="anchor" id="3.3"></a> </dd></dl>
<dl class="user"><dt><b>Thread Safety: </b></dt><dd>This component is <em>NOT</em> thread safe. If it is desired to create a batch of CONFIRM messages from multiple threads, an instance of the builder must be created and maintained <em>per</em> <em>thread</em>. </dd></dl>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Thu Jun 15 2023 11:58:51 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.1 </small></address>
</body>
</html>
